/// @tags: diff
#include <algorithm>
#include <cctype>
#include <cstdio>

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

const int N = 55;
int n, s1, s2;
int dx[N][N], dn[N][N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P2474 [SCOI2008]天平.in", "r", stdin);
  freopen("P2474 [SCOI2008]天平.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &s1, &s2);
  char a[N];
  for (int i = 1; i <= n; i++) {
    scanf("%s", a + 1);
    for (int j = 1; j <= n; j++) {
      if (a[j] == '=' || i == j) {
        dn[i][j] = dx[i][j] = 0;
      } else if (a[j] == '+') {
        dx[i][j] = 2;
        dn[i][j] = 1;
      } else if (a[j] == '-') {
        dx[i][j] = -1;
        dn[i][j] = -2;
      } else {
        dx[i][j] = 2;
        dn[i][j] = -2;
      }
    }
  }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (i != j) {
          dx[i][j] = std::min(dx[i][j], dx[i][k] + dx[k][j]);
          dn[i][j] = std::max(dn[i][j], dn[i][k] + dn[k][j]);
        }
      }
    }
  int c1 = 0, c2 = 0, c3 = 0;
  for (int i = 1; i <= n; ++i) {
    if (i == s1 || i == s2) continue;
    for (int j = 1; j < i; ++j) {
      if (j == s1 || j == s2) continue;
      if (dn[s1][i] > dx[j][s2] || dn[s2][i] > dx[j][s1]) c1++;
      if (dn[i][s1] > dx[s2][j] || dn[i][s2] > dx[s1][j]) c3++;
      if ((dn[s1][i] == dx[s1][i] && dn[j][s2] == dx[j][s2] &&
           dn[s1][i] == dn[j][s2]) ||
          (dn[s1][j] == dx[s1][j] && dn[i][s2] == dx[i][s2] &&
           dn[s1][j] == dn[i][s2]))
        c2++;
    }
  }
  printf("%d %d %d", c1, c2, c3);
  return 0;
}